feat: support uv-managed Python Actors in apify create#1274
Conversation
l2ysho
left a comment
There was a problem hiding this comment.
This seems fine 🚀 . Added some questions and nits. Only thing worth of attention is https://github.com/apify/apify-cli/pull/1274/changes#r3586664002 but it is non-blocking.
also it would be fine to ad some tests (at least happy path).
| 'This Actor uses uv to manage its dependencies, but the uv executable was not found. ' + | ||
| 'Install uv (https://docs.astral.sh/uv/getting-started/installation/), then run "uv sync" in the Actor directory.', | ||
| }); | ||
| return; |
There was a problem hiding this comment.
Suggestion: we should check for uvPath also in getInstallCommandSuggestion otherwise we recommend pip install after this warning (or after --skip-dependency-install)
something like this maybe 🔽 ?
} else if (project.type === ProjectLanguage.Python || project.type === ProjectLanguage.Scrapy) {
const hasUvLock = await stat(join(actFolderDir, 'uv.lock')).then(() => true).catch(() => false);
installCommandSuggestion = hasUvLock ? 'uv sync' : 'python -m pip install -r requirements.txt';
}| await execWithLog({ | ||
| cmd: uvPath, | ||
| args: ['sync'], | ||
| opts: { cwd: actFolderDir }, | ||
| }); |
There was a problem hiding this comment.
Question: "pip way" now ignores skipOptionalDeps flag, is this the same for uv? does uv have something for optional deps?
| const hasUvLock = await stat(join(actFolderDir, 'uv.lock')) | ||
| .then(() => true) | ||
| .catch(() => false); |
There was a problem hiding this comment.
Nit: now we run it also for javascript projects, maybe we can move it to isPythonProject code block?
| // environment, dependencies, and Python version. Install them with `uv sync` instead of the | ||
| // pip + requirements.txt flow. uv provides the Python pinned in `.python-version` on its own, | ||
| // so this runs even when no system Python is detected. | ||
| const isPythonProject = project.type === ProjectLanguage.Python || project.type === ProjectLanguage.Scrapy; |
There was a problem hiding this comment.
Question: does it make sense to introduce new parameters in project level so we do not need to check for uv.lock? Or make uv part of project.packageManager?
apify createhard-codedpip install -r requirements.txtfor Python Actors, so creating a uv-managed template — which shipspyproject.toml+uv.lockand norequirements.txt— failed during dependency install withCould not open requirements file.createnow detects uv-managed Python/Scrapy projects by the presence of a committeduv.lockand installs their dependencies withuv syncinstead. The check runs before the system-Python detection, since uv provides the interpreter pinned in.python-versionitself, and falls back to a warning with install instructions when theuvexecutable isn't found.This unblocks the upcoming
python-uvtemplate (apify/actor-templates#800).